package com.questionnaire.config.properties;


import com.questionnaire.config.webConfig.SpringContextUtil;
import org.apache.commons.lang.StringUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.io.File;
import java.util.Date;


/**
 * guns项目配置
 *
 * @author stylefeng
 * @Date 2017/5/23 22:31
 */
@Component
@ConfigurationProperties(prefix = GunsProperties.PREFIX)
public class GunsProperties {

    public static final String PREFIX = "que";//mty 从guns改成 hbsei
    private Boolean swaggerOpen = false;

    /**
     * session 失效时间（默认为30分钟 单位：秒）
     */
    private Integer sessionInvalidateTime = 30 * 60;

    /**
     * session 验证失效时间（默认为15分钟 单位：秒）
     */
    private Integer sessionValidationInterval = 15 * 60;



    public Integer getSessionValidationInterval() {
        return sessionValidationInterval;
    }

    public void setSessionValidationInterval(Integer sessionValidationInterval) {
        this.sessionValidationInterval = sessionValidationInterval;
    }
    public Integer getSessionInvalidateTime() {
        return sessionInvalidateTime;
    }
    /**
     * 是否单应用登入
     * @return true 是
     *         false 否
     */
    public boolean isSingleLogin(){
        boolean isCALogin = true;
        if ("produce".equals(SpringContextUtil.getActiveProfile())) {
            isCALogin = false;
            //测试环境
        } else if ("test".equals(SpringContextUtil.getActiveProfile())) {
            isCALogin = false;
            //其它环境
        } else if ("dev".equals(SpringContextUtil.getActiveProfile())) {
            isCALogin = false;
            //其它环境
        } else {
            isCALogin = false;
        }
        return isCALogin;
    }

    @Override
    public String toString() {
        return "GunsProperties{" +
                "swaggerOpen=" + swaggerOpen +
                ", sessionInvalidateTime=" + sessionInvalidateTime +
                ", sessionValidationInterval=" + sessionValidationInterval +
                '}';
    }

    public Boolean getSwaggerOpen() {
        return swaggerOpen;
    }

    public void setSwaggerOpen(Boolean swaggerOpen) {
        this.swaggerOpen = swaggerOpen;
    }
}
